define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'member/index',
                    add_url: 'member/add',
                    edit_url: 'member/edit',
                    del_url: 'member/del',
                    multi_url: 'member/multi',
                    table: 'member',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'user_name', title: __('User_name')},
                        {field: 'wechat_name', title:'微信昵称'},
                        {field: 'birthday', title: __('Birthday'), operate:'RANGE', addclass:'datetimerange'},
                        {field: 'mobile', title: __('Mobile')},
                        {field: 'wechat', title: __('Wechat')},
                        {field: 'avatar', title: __('Avatar'),formatter: Table.api.formatter.image, operate: false},
                        {field: 'headimgurl', title:'微信头像',formatter: Table.api.formatter.image, operate: false},
                        {field: 'gender', title: __('Gender'), searchList: {"0":__('Gender 0'),"1":__('Gender 1')}, formatter: Table.api.formatter.normal},
                        {field: 'live_city', title: __('Live_city')},
                        {field: 'authen_status', title: __('Authen_status'), searchList: {"0":__('Authen_status 0'),"1":__('Authen_status 1')}, formatter: Table.api.formatter.status},
                        {field: 'rec_status', title: __('Rec_status'), searchList: {"0":__('Rec_status 0'),"1":__('Rec_status 1')}, formatter: Table.api.formatter.status},
                        {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        /*{field: 'car.name', title: __('车辆状况')},*/
                        /*{field: 'house.name', title: __('房产状况')},*/
                        /*{field: 'income.name', title: __('收入状况')},*/
                        /*{field: 'education.name', title: __('教育状况')},*/
                        /*{field: 'marriage.name', title: __('婚况')},*/
                        /*{field: 'zodiac.name', title: __('星座')},*/
                        /*{field: 'tags.title', title: __('标签')},*/
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});